<template>
  <v-form label-width="150" ref="ruleForm" :fields="fields" :fieldsData="ruleForm"></v-form>
</template>
<script>
import formMinxin from "_c/forms/minxins/formMinxin.js";
import { getCommonOptions } from '@/api/common'

export default {
  mixins: [formMinxin],
  props: {
    patchData: Object,
  },
  data() {
    return {
      ruleForm: {
        defId: "",
        name: "",
        type: ""
      },
      typeList: [],
    };
  },
  computed: {
    fields() {
      return [
        {
          label: "流程名称：",
          placeholder: "请输入流程名称",
          prop: "name",
          type: "text",
          rule: [
            {
              required: true,
              message: "请输入",
              trigger: "blur",
            },
          ],
        },
        {
          label: "业务类型：",
          placeholder: "请选择业务类型",
          prop: "type",
          type: "select",
          options: this.typeList,
          rule: [
            {
              required: true,
              message: "请选择",
              trigger: "blur",
            },
          ],
        },
      ];
    },
  },
  watch: {
    patchData: {
      handler() {
        getCommonOptions('YWLX').then(res => {
          this.typeList = res.data.map(d => ({ value: d.dmcode, label: d.dmname }))
        });
        this.initForm(this.patchData);
      },
      immediate: true,
      deep: true
    },
  },
};
</script>